<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');

class giayto_Controller extends Controller {

    function __construct(){
        parent::__construct('hethong', 'giayto');
        $this->check_login();
        $this->view->template->menu_html =$this->CREATE_MENU();
        $this->view->template->nhacviec_html =$this->CREATE_NHAC_VIEC(); 
        $this->CHECK_QUYEN('hethong', 'giayto');
    }

    function main(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->dsp_all_giayto();
    }
     private function _save_filter(){
        $v_MA_LINH_VUC_THU_TUC_filter = $this->get_post_var('cbx_MA_LINH_VUC_THU_TUC_filter');
        return array(
            'cbx_MA_LINH_VUC_THU_TUC_filter' => $v_MA_LINH_VUC_THU_TUC_filter
        );
    }
    function dsp_all_giayto(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $arr_filter = $this->_save_filter();
        $VIEW_DATA['arr_filter']                   = $arr_filter;
        $VIEW_DATA['arr_all_giayto']               = $this->model->qry_all_giayto_filter($arr_filter);
        $VIEW_DATA['arr_all_linhvucthutuc_filter'] = $this->model->SELECT_LINHVUCTHUTUC_tatca();
        $this->view->render('dsp_all_giayto', $VIEW_DATA);
    }
    public function dsp_single_giayto($MA_GIAY_TO){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $MA_GIAY_TO = replace_bad_char($MA_GIAY_TO);
        $VIEW_DATA['arr_single_giayto'] = $this->model->qry_single_giayto($MA_GIAY_TO);
        $VIEW_DATA['arr_all_linhvucthutuc'] = $this->model->SELECT_LINHVUCTHUTUC_nothing();
        $this->view->render('dsp_single_giayto', $VIEW_DATA);
    }
    public function update_giayto(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_giayto';
        $this->model->update_giayto();
    }
    public function delete_giayto(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_giayto';
        $this->model->delete_giayto();
    }
}